<template>
  <div>
    <ul>
      <li v-for="(v, i) in arr" :key="i">
        <div id="shop">
          <div id="left">

            <span class="input-group-addon">
              <input type="checkbox"   aria-label="..."  @click="fun(i)"  id="Selectall" style="border-radius: 50%;"/>
            </span>

            <span>
              <img src="../../../public/img/1.png" alt="" />
            </span>
          </div>
          <div id="right">
            <p>{{ v.titi }}</p>
            <span>￥{{ v.num }}</span>
            <div class="input-group">
              <button type="submit" class="btn btn-primary">-</button>
              <input
                type="text"
                class="form-control"
                id="exampleInputAmount"
                v-text="1"
              />
              <button type="submit" class="btn btn-primary">+</button>
            </div>
          </div>
        </div>
        <!-- -------{{ v.style }} -->
      </li>
    </ul>
    <p>总价:{{ newzong }}</p>
  </div>
</template>

<script>
import { getlink } from "a/getlink.js";
export default {
  data() {
    return {
      arr: [],
      zong: 0.0,
    };
  },
  methods: {
    shopcar() {
      getlink("/shoping/shopingcar").then((ok) => {
        // console.log(ok.data.shoping)
        this.arr = ok.data.shoping;
        console.log(this.arr);
      });
    },
    fun(i) {
      this.arr[i].style = !this.arr[i].style;
      if (this.arr[i].style) {
        this.zong += this.arr[i].num;
      } else {
        this.zong -= this.arr[i].num;
      }
    },
  },
  computed: {
    newzong() {
      return parseFloat(this.zong).toFixed(2);
    },
  },
  created() {
    this.shopcar();
  },
};
</script>

<style scoped>
div{
  font-size: 0.2rem;
}
li {
  
  width: 99%;
  height: 0.8rem;
  border: 1px solid red;
  margin-top: 0.2rem;
}
#exampleInputAmount {
  width: 0.2rem;
  margin: 0rem 0.1rem 0rem 0.1rem;
}
.btn {
  width: 0.2rem;
}
#shop {
  display: flex;
  justify-content: space-between;
}

.input-group {
  position: absolute;
  bottom: 0.1rem;
  right: 0.1rem;
}
#right span {
  display: block;
  position: absolute;
  bottom: 0.1rem;
}
.input-group-addon {
  line-height: 0.8rem;
}
#left,
#right {
  display: flex;
  border: 1px solid black;
}
#left {
  box-sizing: border-box;
  padding: 0rem 0.1rem 0rem 0.1rem;
  width: 2rem;
}
#right {
  position: relative;
  width: 2rem;
}
img{
  margin:0.05rem 0.1rem 0rem 0.1rem;
  width: 0.7rem;
  height: 0.7rem;
}
#Selectall{
  width: 0.3rem;
  height: 0.3rem;
  -webkit-border-: 50%;
    border-radius: 50%;
  /* -webkit-appearance: none; */
  /* border: 1px solid black;	 */
  
  
}
</style>
